<template>
  <div style="">
    <el-card class="box-card">
      <div>程序设计 &nbsp;&nbsp;{{ scoreData.程序设计 }}</div>
      <div>大学物理 &nbsp;&nbsp;{{ scoreData.大学物理 }}</div>
      <div>大学英语 &nbsp;&nbsp;{{ scoreData.大学英语 }}</div>
      <div>高等数学 &nbsp;&nbsp;{{ scoreData.高等数学 }}</div>
      <hr />
      <div class="zcf">综测分:{{fen}}</div>
    </el-card>
  </div>
</template>

<script>
export default {
  mounted() {
    this.getScore();
    this.getZc()
  },
  data() {
    return {
      scoreData: {},
      zc: {},
      fen: 0,
    };
  },
  methods: {
    getScore() {
      let user = JSON.parse(localStorage.getItem("user"));
      this.request.get("/score/getScore/" + user.username).then((resp) => {
        this.scoreData = resp.data;
      });
    },
    getZc() {
      this.request.get("/score/getZc").then((reps) => {
        debugger
        this.fen = 0.0;
        reps.data.forEach((element) => {
          if (element.name == "大学物理") {
            //计算大学物理分数
            this.fen +=
              parseFloat(this.scoreData.大学物理) * parseFloat(element.weight)/100;
          } else if (element.name == "高等数学") {
            //计算高等数学分数
            this.fen +=
              parseFloat(this.scoreData.高等数学) * parseFloat(element.weight)/100;
          } else if (element.name == "大学英语") {
            //计算大学英语分数
            this.fen +=
              parseFloat(this.scoreData.大学英语) * parseFloat(element.weight)/100;
          } else {
            //计算程序设计分数
            this.fen +=
              parseFloat(this.scoreData.程序设计) * parseFloat(element.weight)/100;
          }
        });
      });
    },
  },
};
</script>

<style scoped>
.box-card div {
  margin: 5px;
}
.zcf {
  font-size: 24px;
}
</style>

